

import 'package:bt_tool/basic/bt_controller.dart';
import 'package:bt_tool/widget/bt_base_btn_widget.dart';
import 'package:bt_tool/widget/bt_text_field.dart';
import 'package:bt_tool/widget/bt_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo/tools/encode/encode_main_controller.dart';
import '../../common/config/app_theme_color_config.dart';


class EncodeMainPage extends BTStatefulWidget{

  const EncodeMainPage({super.key,super.routerConfig});

  @override
  State<StatefulWidget> createState() {
    return EncodeMainPageState();
  }
}


class EncodeMainPageState extends BTState<EncodeMainPage>{

  final EncodeMainController ctl = EncodeMainController();

  @override
  BTController btCtrl() {
    return ctl;
  }



  @override
  Widget build(BuildContext context) {
    return Container(
      constraints: const BoxConstraints.expand(),
      padding: const EdgeInsets.all(10),
      color: AppThemeColor.contentBgColor,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          const Text("转换内容"),
          const SizedBox(height: 10,),
          Expanded(child: Container(
            constraints: const BoxConstraints.expand(),
            child: BTTextFieldWidget(
              btTextFieldController: ctl.inputCtl,
              maxLine: BTTextFieldWidget.maxLineDefine,
              isIgnoreClearBtn: true,
            ),
          )),
          const SizedBox(height: 10,),
          const Text("转换结果"),
          const SizedBox(height: 10,),
          Expanded(child:Container(
              constraints: const BoxConstraints.expand(),
              child: BTTextFieldWidget(
                btTextFieldController: ctl.resultCtl,
                maxLine: BTTextFieldWidget.maxLineDefine,
                isIgnoreClearBtn: true,
              ),
            ),),
          const SizedBox(height: 15,),
          Row(
            children: [
              BTBtnTextWidget(
                bgColor: AppThemeColor.mainColor,
                constraints: const BoxConstraints.expand(width: 100,height: 40),
                text: "Encode",
                textColor: Colors.white,
                onTap: () => ctl.encodeClick(),
                alignment: Alignment.center,
              ),
              const SizedBox(width: 10,),
              BTBtnTextWidget(
                bgColor: AppThemeColor.mainColor,
                constraints: const BoxConstraints.expand(width: 100,height: 40),
                text: "Decode",
                textColor: Colors.white,
                onTap: () => ctl.decodeClick(),
                alignment: Alignment.center,
              ),
              Expanded(
                child: Align(
                  alignment: Alignment.centerRight,
                  child: BTBtnTextWidget(
                    bgColor: AppThemeColor.mainColor,
                    constraints: const BoxConstraints.expand(width: 100,height: 40),
                    text: "交换内容",
                    textColor: Colors.white,
                    onTap: () => ctl.exchangeClick(),
                    alignment: Alignment.center,
                  ),
                ),
              )
            ],
          ),
        ],
      ),
    );
  }

}